package com.ywh.hilttest.test1

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.ywh.hilttest.test1.dynamic_param.ILocalDynamicParamObjectFactory
import com.ywh.hilttest.test1.dynamic_param.LocalDynamicParamObject
import com.ywh.hilttest.test1.dynamic_param2.LocalDynamicParam2Object
import com.ywh.hilttest.test1.dynamic_param2.LocalDynamicParam2ObjectFactory
import com.ywh.hilttest.test1.no_param.LocalObject
import com.ywh.hilttest.test1.static_param.LocalStaticParamObject
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class FragmentLocalObject : Fragment() {
    //本地无参对象
    @Inject
    lateinit var localObject: LocalObject

    //本地带固定参数对象
    @Inject
    lateinit var localStaticParamObject: LocalStaticParamObject

    //通过工厂动态传参方式1
    @Inject
    lateinit var localDynamicParamObjectFactory: ILocalDynamicParamObjectFactory

    //通过工厂动态传参方式2
    @Inject
    lateinit var localDynamicParam2ObjectFactory: LocalDynamicParam2ObjectFactory

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        localObject.test()

        localStaticParamObject.test()

        val localDynamicParamObject: LocalDynamicParamObject =
            localDynamicParamObjectFactory.create("123456789")
        localDynamicParamObject.test()

        val localDynamicParam2Object: LocalDynamicParam2Object =
            localDynamicParam2ObjectFactory.createObject("0987654321")
        localDynamicParam2Object.test()
    }
}